package com.yf1706.tags;

import java.io.IOException;
import java.util.Set;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class GrantTag extends SimpleTagSupport{
	private Integer id;
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public Integer getId() {
		return id;
	}
	
	@Override
	public void doTag() throws JspException, IOException {
		//从session 获取当前登录用户的全部权限ID
		HttpSession session = ((PageContext)this.getJspContext()).getSession();
		Set<Integer> funcIds = (Set<Integer>) session.getAttribute("funIds");
		if(funcIds != null){
			//判断标签传过来的ID是否在权限列表中存在
			if(funcIds.contains(this.id)){
				//输出标签体内容
				getJspBody().invoke(null);
			}
		}
	}
}
